package com.yang.webapi.module.controller;

import com.yang.service.model.vo.UserVO;
import com.yang.webapi.module.service.UserWebService;
import com.zhy.base.webapi.annoation.ResponseFormatter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;


@RestController
@ResponseFormatter
@RequestMapping(value = "login")
@CrossOrigin
@Slf4j
@Api(tags = "登录管理", description = "LoginController")
public class LoginController {

    @Autowired
    private UserWebService userWebService;


    @ApiOperation(value = "微信登录")
    @ApiImplicitParam(name = "code", value = "微信授权码", required = true)
    @PostMapping("wechat/{code}")
    public UserVO userWxLogin(@PathVariable(value = "code") String code) throws IOException {
        log.info("从前端获取的Code:" + code);
        return userWebService.weChatLogin(code);
    }

}
